import React, { useEffect, useState } from "react";
import $ from '../axios'
export default function Sell() {
  let [list, setList] = useState([]);
  useEffect(() => {
    getlist();
  }, []);
  let getlist = async () => {
    let { data } = await $.get("/getOrder");
    setList(data.data);
  };
  return (
    <div>
      {list
        .filter((ele) => {
          return ele.type == "卖";
        })
        .map((item) => {
          return (
            <div key={item._id} style={{ display: "flex", margin: "20px 0" }}>
              <div style={{ width: "30%" }}>
                <img
                  src={item.img}
                  style={{
                    width: "100px",
                    height: "100px",
                  }}
                />
              </div>
              <div style={{ width: "68%" }}>
                <p>{item.title}</p>
                <p style={{ color: "red", fontSize: "16px", fontWeight: 600 }}>
                  ￥{item.price}
                </p>
                <p
                  style={{
                    overflow: "hidden",
                    whiteSpace: "nowrap",
                    textOverflow: "ellipsis",
                  }}
                >
                  {item.content}
                </p>
                <p>买家：{item.buyers}</p>
                <p>卖家：{item.seller}</p>
                <p>物流信息：{item.wuliu}</p>
                <p>{item.paystatus ? "未支付" : "已支付"}</p>
              </div>
            </div>
          );
        })}
    </div>
  );
}
